package com.movies.service.controller.user;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.movies.service.common.Constants;
import com.movies.service.common.Result;
import com.movies.service.entity.Seat;
import com.movies.service.service.SeatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/user/seat")
@SaCheckLogin
public class UserSeatController {

    @Autowired
    private SeatService seatService;

//    按影院与影厅查询全部座位
    @GetMapping("/list")
    public Result list(@RequestParam Long cinemaId,
                       @RequestParam String hallName) {
        if (cinemaId == null || hallName == null || hallName.isEmpty()) {
            return Result.error(Constants.CODE_600, "影院ID与影厅名称必填");
        }
        LambdaQueryWrapper<Seat> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Seat::getCinemaId, cinemaId).eq(Seat::getHallName, hallName);
        List<Seat> seats = seatService.list(wrapper);
        return Result.success(seats);
    }
}